import { stringify } from 'qs';
import request from '../utils/request';

/*利用json-server数据*/
export async function peoplelist() {
  //查列表数据
  return request('http://localhost:3000/people', {
    method: 'GET',
  });
}
export async function creatpeople(params) {
  //增添数据
  return request('http://localhost:3000/people', {
    method: 'POST',
    body: params,
  });
}
export async function removepeople(params) {
  //删除数据
  return request('http://localhost:3000/people/' + params, {
    method: 'DELETE',
  });
}
export async function peopleDetail(params) {
  //详情数据
  return request(`http://localhost:3000/people/${params}`, {
    method: 'GET',
  });
}
export async function updatePeople(id, values) {
  //修改数据
  return request(`http://localhost:3000/people/${id}`, {
    method: 'PATCH',
    body: values,
  });
}
export async function queryPeople(params) {
  //表单条件查询
  return request(`http://localhost:3000/people?${stringify(params)}`, {
    method: 'GET',
  });
}
//下拉列表数据
export async function cateList() {
  //查列表数据
  return request('http://localhost:3000/cateList', {
    method: 'GET',
  });
}
export async function actionlist() {
  //查用户操作权限列表
  return request('http://localhost:3000/action', {
    method: 'GET',
  });
}
export async function queryAction(params) {
  console.log(params);
  //用户权限列表条件查询
  return request(`http://localhost:3000/action?${stringify(params)}`, {
    method: 'GET',
  });
}
export async function peopleactiondetail(params) {
  //查看用户权限详情数据
  return request(`http://localhost:3000/action/${params}`, {
    method: 'GET',
  });
}
export async function updateAction(id, values) {
  //修改数据
  return request(`http://localhost:3000/action/${id}`, {
    method: 'PATCH',
    body: values,
  });
}
export async function removepeopleaction(params) {
  //删除数据
  return request('http://localhost:3000/action/' + params, {
    method: 'DELETE',
  });
}